﻿<catel:UserControl x:Class="Catel.Examples.WinRT.Advanced.Views.HouseView"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                   xmlns:catel="using:Catel.Windows.Controls" 
                   xmlns:views="using:Catel.Examples.WinRT.Advanced.Views" 
                   xmlns:catelconverters="using:Catel.Windows.Data.Converters" mc:Ignorable="d"
                   d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.Resources>
        <catelconverters:FormattingConverter x:Key="FormattingConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Image Grid.Row="0" Grid.Column="0" Source="/Resources/Images/house.png"
               Width="48" Height="48"/>

        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center" />

        <TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding ViewModelConstructionTime, Converter={StaticResource FormattingConverter}, ConverterParameter='ViewModel created at \{0:HH:mm:ss.fff\}'}" />

        <StackPanel Grid.Row="2" Grid.ColumnSpan="2">
            <TextBlock Text="Rooms" HorizontalAlignment="Left" VerticalAlignment="Center" />
            
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <ItemsControl Grid.Column="1" ItemsSource="{Binding Rooms}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <views:RoomView DataContext="{Binding}" />
                                <Line Height="2" />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </StackPanel>
    </Grid>
    
</catel:UserControl>
